package com.google.android.gms.internal;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.MutableContextWrapper;
import android.net.Uri;
import android.view.MotionEvent;
import android.webkit.DownloadListener;
import android.webkit.WebView;

public class ex extends WebView implements DownloadListener {
    private final Object ls;
    private al nF;
    private final k pA;
    private final a sB;
    private boolean sD;
    private boolean sF;

    private static class a extends MutableContextWrapper {
        private Context lz;
        private Activity sG;

        public void setBaseContext(Context base) {
            this.lz = base.getApplicationContext();
            this.sG = base instanceof Activity ? (Activity) base : null;
            super.setBaseContext(this.lz);
        }

        public void startActivity(Intent intent) {
            if (this.sG != null) {
                this.sG.startActivity(intent);
                return;
            }
            intent.setFlags(268435456);
            this.lz.startActivity(intent);
        }
    }

    public void destroy() {
        synchronized (this.ls) {
            super.destroy();
            this.sF = true;
        }
    }

    public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long size) {
        try {
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setDataAndType(Uri.parse(url), mimeType);
            getContext().startActivity(intent);
        } catch (ActivityNotFoundException e) {
            eu.z("Couldn't find an Activity to view url/mimetype: " + url + " / " + mimeType);
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    protected void onMeasure(int r10, int r11) {
        /*
        r9 = this;
        r0 = 2147483647; // 0x7fffffff float:NaN double:1.060997895E-314;
        r8 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
        r7 = 8;
        r6 = -2147483648; // 0xffffffff80000000 float:-0.0 double:NaN;
        r4 = r9.ls;
        monitor-enter(r4);
        r1 = r9.isInEditMode();	 Catch:{ all -> 0x00ae }
        if (r1 != 0) goto L_0x0016;
    L_0x0012:
        r1 = r9.sD;	 Catch:{ all -> 0x00ae }
        if (r1 == 0) goto L_0x001b;
    L_0x0016:
        super.onMeasure(r10, r11);	 Catch:{ all -> 0x00ae }
        monitor-exit(r4);	 Catch:{ all -> 0x00ae }
    L_0x001a:
        return;
    L_0x001b:
        r2 = android.view.View.MeasureSpec.getMode(r10);	 Catch:{ all -> 0x00ae }
        r3 = android.view.View.MeasureSpec.getSize(r10);	 Catch:{ all -> 0x00ae }
        r5 = android.view.View.MeasureSpec.getMode(r11);	 Catch:{ all -> 0x00ae }
        r1 = android.view.View.MeasureSpec.getSize(r11);	 Catch:{ all -> 0x00ae }
        if (r2 == r6) goto L_0x002f;
    L_0x002d:
        if (r2 != r8) goto L_0x00c7;
    L_0x002f:
        r2 = r3;
    L_0x0030:
        if (r5 == r6) goto L_0x0034;
    L_0x0032:
        if (r5 != r8) goto L_0x0035;
    L_0x0034:
        r0 = r1;
    L_0x0035:
        r5 = r9.nF;	 Catch:{ all -> 0x00ae }
        r5 = r5.widthPixels;	 Catch:{ all -> 0x00ae }
        if (r5 > r2) goto L_0x0041;
    L_0x003b:
        r2 = r9.nF;	 Catch:{ all -> 0x00ae }
        r2 = r2.heightPixels;	 Catch:{ all -> 0x00ae }
        if (r2 <= r0) goto L_0x00b1;
    L_0x0041:
        r0 = r9.sB;	 Catch:{ all -> 0x00ae }
        r0 = r0.getResources();	 Catch:{ all -> 0x00ae }
        r0 = r0.getDisplayMetrics();	 Catch:{ all -> 0x00ae }
        r0 = r0.density;	 Catch:{ all -> 0x00ae }
        r2 = new java.lang.StringBuilder;	 Catch:{ all -> 0x00ae }
        r2.<init>();	 Catch:{ all -> 0x00ae }
        r5 = "Not enough space to show ad. Needs ";
        r2 = r2.append(r5);	 Catch:{ all -> 0x00ae }
        r5 = r9.nF;	 Catch:{ all -> 0x00ae }
        r5 = r5.widthPixels;	 Catch:{ all -> 0x00ae }
        r5 = (float) r5;	 Catch:{ all -> 0x00ae }
        r5 = r5 / r0;
        r5 = (int) r5;	 Catch:{ all -> 0x00ae }
        r2 = r2.append(r5);	 Catch:{ all -> 0x00ae }
        r5 = "x";
        r2 = r2.append(r5);	 Catch:{ all -> 0x00ae }
        r5 = r9.nF;	 Catch:{ all -> 0x00ae }
        r5 = r5.heightPixels;	 Catch:{ all -> 0x00ae }
        r5 = (float) r5;	 Catch:{ all -> 0x00ae }
        r5 = r5 / r0;
        r5 = (int) r5;	 Catch:{ all -> 0x00ae }
        r2 = r2.append(r5);	 Catch:{ all -> 0x00ae }
        r5 = " dp, but only has ";
        r2 = r2.append(r5);	 Catch:{ all -> 0x00ae }
        r3 = (float) r3;	 Catch:{ all -> 0x00ae }
        r3 = r3 / r0;
        r3 = (int) r3;	 Catch:{ all -> 0x00ae }
        r2 = r2.append(r3);	 Catch:{ all -> 0x00ae }
        r3 = "x";
        r2 = r2.append(r3);	 Catch:{ all -> 0x00ae }
        r1 = (float) r1;	 Catch:{ all -> 0x00ae }
        r0 = r1 / r0;
        r0 = (int) r0;	 Catch:{ all -> 0x00ae }
        r0 = r2.append(r0);	 Catch:{ all -> 0x00ae }
        r1 = " dp.";
        r0 = r0.append(r1);	 Catch:{ all -> 0x00ae }
        r0 = r0.toString();	 Catch:{ all -> 0x00ae }
        com.google.android.gms.internal.eu.D(r0);	 Catch:{ all -> 0x00ae }
        r0 = r9.getVisibility();	 Catch:{ all -> 0x00ae }
        if (r0 == r7) goto L_0x00a6;
    L_0x00a2:
        r0 = 4;
        r9.setVisibility(r0);	 Catch:{ all -> 0x00ae }
    L_0x00a6:
        r0 = 0;
        r1 = 0;
        r9.setMeasuredDimension(r0, r1);	 Catch:{ all -> 0x00ae }
    L_0x00ab:
        monitor-exit(r4);	 Catch:{ all -> 0x00ae }
        goto L_0x001a;
    L_0x00ae:
        r0 = move-exception;
        monitor-exit(r4);	 Catch:{ all -> 0x00ae }
        throw r0;
    L_0x00b1:
        r0 = r9.getVisibility();	 Catch:{ all -> 0x00ae }
        if (r0 == r7) goto L_0x00bb;
    L_0x00b7:
        r0 = 0;
        r9.setVisibility(r0);	 Catch:{ all -> 0x00ae }
    L_0x00bb:
        r0 = r9.nF;	 Catch:{ all -> 0x00ae }
        r0 = r0.widthPixels;	 Catch:{ all -> 0x00ae }
        r1 = r9.nF;	 Catch:{ all -> 0x00ae }
        r1 = r1.heightPixels;	 Catch:{ all -> 0x00ae }
        r9.setMeasuredDimension(r0, r1);	 Catch:{ all -> 0x00ae }
        goto L_0x00ab;
    L_0x00c7:
        r2 = r0;
        goto L_0x0030;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.ex.onMeasure(int, int):void");
    }

    public boolean onTouchEvent(MotionEvent event) {
        if (this.pA != null) {
            this.pA.a(event);
        }
        return super.onTouchEvent(event);
    }

    public void setContext(Context context) {
        this.sB.setBaseContext(context);
    }
}
